package com.yy.jhl.ui.user.activity;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.yy.common.base.BaseActivity;
import com.yy.common.commonutils.ImageLoaderUtils;
import com.yy.common.commonutils.StringUtil;
import com.yy.common.commonwidget.OnDoubleClickListener;
import com.yy.common.commonwidget.OnNoDoubleClickListener;
import com.yy.jhl.R;
import com.yy.jhl.bean.LoginInfo;
import com.yy.jhl.interfaces.UserInfoCallBack;
import com.yy.jhl.util.DataRequestUtil;
import com.yy.jhl.util.DataUtil;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by libingn on 2017/12/4.
 */

public class PersonInfoActivity extends BaseActivity {


    @BindView(R.id.person_logo)
    ImageView personLogo;
    @BindView(R.id.person_logo_parent)
    LinearLayout personLogoParent;
    @BindView(R.id.person_name)
    TextView personName;
    @BindView(R.id.person_name_parent)
    LinearLayout personNameParent;
    @BindView(R.id.contact_phone)
    TextView contactPhone;
    @BindView(R.id.contact_phone_parent)
    LinearLayout contactPhoneParent;

    @Override
    public int getLayoutId() {
        return R.layout.act_person_info;
    }

    @Override
    public void initView() {
        showTitle("个人资料", new OnNoDoubleClickListener() {
            @Override
            protected void onNoDoubleClick(View v) {
                finish();
            }
        });
        showData();
    }

    private void showData() {
        LoginInfo.UserBean userInfo = DataUtil.getUserInfo(mContext);
        personName.setText(StringUtil.isEmpty(userInfo.getNickname()) ? userInfo.getUsername() : userInfo.getNickname());
        contactPhone.setText(StringUtil.isEmpty(userInfo.getMobile_phone()) ? "" : userInfo.getMobile_phone());
        if (!StringUtil.isEmpty(userInfo.getAvatar())){
            ImageLoaderUtils.displayRound(mContext,personLogo,userInfo.getAvatar(),R.mipmap.cgs_logo);
        }
    }

    @Override
    protected void onResume() {
        super.onResume();
        DataRequestUtil.getInstance(mContext).getUserInfo(new UserInfoCallBack() {
            @Override
            public void getCallBack(LoginInfo.UserBean userBean) {
                showData();
            }
        });
    }

    @OnClick({R.id.person_logo_parent, R.id.person_name_parent, R.id.contact_phone_parent})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.person_logo_parent:
                break;
            case R.id.person_name_parent:
                break;
            case R.id.contact_phone_parent:
                break;
        }
    }
}
